import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

bool turn_on = true;
bool mic_on = false;

int rgbIndex = 0;
String ledNum = '200'; // 存储输入的值

String rgbIndexKey = 'rgbIndexKey';
String ledNumKey = 'ledNumKey';

///主题背景颜色
const Color Color_red = Color(0xFFCC2D1F);
const Color Color_mid = Color(0xFF4088B0);
const Color Color_theme = Color(0xFFE18030);
const Color Color_bg_view = Color(0xFF8D8D8D);
const Color Color_bar = Color(0xFF0A0909);
const Color Color_border = Colors.black;
const Color Color_bg_view2 = Color(0xFF39393D);
const Color Color_disEnable = Color(0xFF8F989C);
const Color Color_purple = Color(0xFF85519C);
const Color Color_green = Color(0xFF6CB930);
const Color Color_thumbColor = Color(0xFF292F74);
// const fontNormal = TextStyle(fontWeight: FontWeight.w600, color: Colors.black);
// const font20 = TextStyle(color: Colors.black, fontWeight: FontWeight.w600, fontSize: 20);
// const font30 = TextStyle(color: Colors.black, fontWeight: FontWeight.bold, fontSize: 30);
const BankFont = 'BankFont';

final fontNormal = font(null);
final font14 = font(14);
final font20 = font(20);
final font30 = font(30);
final font40 = font(40);

TextStyle font(double? font) {
  return TextStyle(
      color: Colors.black, fontFamily: BankFont, fontWeight: FontWeight.bold, height: 1.0, fontSize: font ?? 16);
}

BoxDecoration boxDecoration(double radius) {
  return BoxDecoration(borderRadius: BorderRadius.circular(radius), border: Border.all(color: Colors.black, width: 1));
}

BoxDecoration boxDecorationWithColor(double radius, Color color) {
  return BoxDecoration(
      borderRadius: BorderRadius.circular(radius), color: color, border: Border.all(color: Colors.black, width: 1));
}

const LinearGradient localGradient = LinearGradient(
  begin: Alignment.topLeft, // 渐变的开始位置，左边
  end: Alignment.bottomRight, // 渐变的结束位置，右边
  colors: [
    Colors.black, // 起始颜色
    Colors.purple, // 结束颜色
  ],
);

// // 保存字符串
// Future<void> saveString(String key, String value) async {
//   final prefs = await SharedPreferences.getInstance();
//   await prefs.setString(key, value);
// }

// // 获取字符串
// Future<String?> getString(String key) async {
//   final prefs = await SharedPreferences.getInstance();
//   return prefs.getString(key);
// }

class GlobalConfig {
  static double scaleH = 0.0;
}

class assets {
  static const String _basePath = 'assets/images/';

  static String getImagePath(String imageName) {
    return '$_basePath$imageName.png';
  }

  // 定义具体的图片资源

//首页
  static const String crossover_select = '${_basePath}crossover_select.png';
  static const String crossover = '${_basePath}crossover.png';
  static const String delay_select = '${_basePath}delay_select.png';
  static const String delay = '${_basePath}delay.png';
  static const String eq_select = '${_basePath}eq_select.png';
  static const String eq = '${_basePath}eq.png';
  static const String input_select = '${_basePath}input_select.png';
  static const String input = '${_basePath}input.png';
  static const String level_select = '${_basePath}level_select.png';
  static const String level = '${_basePath}level.png';
  static const String setting_select = '${_basePath}setting_select.png';
  static const String setting = '${_basePath}setting.png';

  static const String voice_on = '${_basePath}voice_on.png';
  static const String voice_off = '${_basePath}voice_off.png';
  static const String thumb = '${_basePath}thumb.png';

  static const String add = '${_basePath}add.png';
  static const String sub = '${_basePath}sub.png';
  static const String arrow_down = '${_basePath}arrow_down.png';

  ///读取本地文件
  static Future<Uint8List?> readBinFile(String fileName) async {
    try {
      // 读取 bin 文件
      ByteData data = await rootBundle.load('assets/$fileName');

      // 将 ByteData 转换为 Uint8List 并返回
      return data.buffer.asUint8List();
    } catch (e) {
      print('Error reading bin file: $e');
      return null;
    }
  }
}
